/******************************************************************************************************
Copyright (C) 2013 Mestrelab Research S.L. All rights reserved.

This file is part of the Mnova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided 
AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, 
MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE.
*****************************************************************************************************/

/*globals verificationCommon*/
/*jslint plusplus: true, indent: 4*/

// This function is used by the Well plate widget. It should return a string containing a valid svg image.
// The function verificationCommon.score2Color is defined in verificationCommon.qs

function WellPlateSvg(aFieldContent) {
    "use strict";
    //print("Content: " + aFieldContent + " (" + number + ")");
    var invalid = parseFloat("-10.0"),
        number = parseFloat(aFieldContent),
        color = "black",
        result = '<?xml version="1.0" standalone="no"?>\n'
              + '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"\n'
              + ' "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'
              + '<svg width="100" height="100" version="1.1"\n'
              + 'xmlns="http://www.w3.org/2000/svg">\n';

    if (verificationCommon === undefined || verificationCommon.score2Color === undefined) {
        color = "grey";
    } else if (isNaN(number)) {
        color = "blue";
    } else if (number === invalid) {
        color  = "white";
    } else if (number < -10.0 || number > 10.0) {
        color = "lightblue";
    } else {
        color = verificationCommon.score2Color(number);
    }

    result += '<circle cx="50" cy="50" r="40" stroke="black" stroke-width="1" fill="' + color + '"/>\n';
    result += '</svg>';
    return result;
}
